package com.js.purs.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.js.purs.domain.PurBindDelv;
import com.js.purs.service.IPurBindDelvService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 投递标书Controller
 * 
 * @author ruoyi
 * @date 20240708
 */
@RestController
@RequestMapping("/delv")
public class PurBindDelvController extends BaseController
{
    @Autowired
    private IPurBindDelvService purBindDelvService;

    /**
     * 查询投递标书列表
     */
    @RequiresPermissions("purs:delv:list")
    @GetMapping("/list")
    public TableDataInfo list(PurBindDelv purBindDelv)
    {
        startPage();
        List<PurBindDelv> list = purBindDelvService.selectPurBindDelvList(purBindDelv);
        return getDataTable(list);
    }

    /**
     * 导出投递标书列表
     */
    @RequiresPermissions("purs:delv:export")
    @Log(title = "投递标书", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PurBindDelv purBindDelv)
    {
        List<PurBindDelv> list = purBindDelvService.selectPurBindDelvList(purBindDelv);
        ExcelUtil<PurBindDelv> util = new ExcelUtil<PurBindDelv>(PurBindDelv.class);
        util.exportExcel(response, list, "投递标书数据");
    }

    /**
     * 获取投递标书详细信息
     */
    @RequiresPermissions("purs:delv:query")
    @GetMapping(value = "/{delvId}")
    public AjaxResult getInfo(@PathVariable("delvId") Long delvId)
    {
        return success(purBindDelvService.selectPurBindDelvByDelvId(delvId));
    }

    /**
     * 新增投递标书
     */
    @RequiresPermissions("purs:delv:add")
    @Log(title = "投递标书", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PurBindDelv purBindDelv)
    {
        return toAjax(purBindDelvService.insertPurBindDelv(purBindDelv));
    }

    /**
     * 新增投递标书
     */
    @PostMapping("/insertDelv")
    public AjaxResult insert(@RequestBody PurBindDelv purBindDelv)
    {
        return toAjax(purBindDelvService.insertPurBindDelv(purBindDelv));
    }

    /**
     * 修改投递标书
     */
    @RequiresPermissions("purs:delv:edit")
    @Log(title = "投递标书", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PurBindDelv purBindDelv)
    {
        return toAjax(purBindDelvService.updatePurBindDelv(purBindDelv));
    }

    /**
     * 删除投递标书
     */
    @RequiresPermissions("purs:delv:remove")
    @Log(title = "投递标书", businessType = BusinessType.DELETE)
	@DeleteMapping("/{delvIds}")
    public AjaxResult remove(@PathVariable Long[] delvIds)
    {
        return toAjax(purBindDelvService.deletePurBindDelvByDelvIds(delvIds));
    }

    /**
     * 通过供应商编码查看是否投标
     */

    @PostMapping("/selectDelvBySupCode")
    public AjaxResult selectDelvBySupCode(@RequestBody PurBindDelv purBindDelv)
    {
        return AjaxResult.success(purBindDelvService.selectPurBindDelvBySupCode(purBindDelv));
    }
}
